/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package com.gxuwz.byssxsys.dao;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.gxuwz.byssxsys.model.*;
import com.gxuwz.byssxsys.dao.*;
import com.gxuwz.byssxsys.service.*;
import com.gxuwz.byssxsys.vo.query.*;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


import static cn.org.rapid_framework.util.ObjectUtils.*;
import org.springframework.stereotype.Repository;

@Repository
public class PromptMessageRecordDao extends BaseHibernateDao<PromptMessageRecord,java.lang.Integer>{

	public Class getEntityClass() {
		return PromptMessageRecord.class;
	}
	
	public Page findPage(PromptMessageRecordQuery query) {
        //XsqlBuilder syntax,please see http://code.google.com/p/rapid-xsqlbuilder
        // [column]为字符串拼接, {column}为使用占位符. [column]为使用字符串拼接,如username='[username]',偷懒时可以使用字符串拼接 
        // [column] 为PageRequest的属性
		String sql = "select t from PromptMessageRecord t where 1=1 "
			  	+ "/~ and t.pmrsender1 = {pmrsender1} ~/"
			  	+ "/~ and t.pmrreceiver2 = {pmrreceiver2} ~/"
				+ "/~ and t.pmrsenderDate3 >= {pmrsenderDate3Begin} ~/"
				+ "/~ and t.pmrsenderDate3 <= {pmrsenderDate3End} ~/"
			  	+ "/~ and t.pmrcontent4 = {pmrcontent4} ~/"
			  	+ "/~ and t.pmrphone5 = {pmrphone5} ~/"
			  	+ "/~ and t.pmremail6 = {pmremail6} ~/"
			  	+ "/~ and t.pmrstatue7 = {pmrstatue7} ~/"
			  	+ "/~ and t.pmrtype8 = {pmrtype8} ~/"
				+ "/~ order by [sortColumns] ~/";

        //生成sql2的原因是为了不喜欢使用xsqlbuilder的同学，请修改生成器模板，删除本段的生成
//        StringBuilder sql2 = new StringBuilder("select t from PromptMessageRecord t where 1=1 ");
//        if(isNotEmpty(query.getId())) {
//            sql2.append(" and  t.id = :id ");
//        }
//        if(isNotEmpty(query.getPmrsender1())) {
//            sql2.append(" and  t.pmrsender1 = :pmrsender1 ");
//        }
//        if(isNotEmpty(query.getPmrreceiver2())) {
//            sql2.append(" and  t.pmrreceiver2 = :pmrreceiver2 ");
//        }
//        if(isNotEmpty(query.getPmrsenderDate3Begin())) {
//            sql2.append(" and  t.pmrsenderDate3 >= :pmrsenderDate3Begin ");
//        }
//        if(isNotEmpty(query.getPmrsenderDate3End())) {
//            sql2.append(" and  t.pmrsenderDate3 <= :pmrsenderDate3End ");
//        }
//        if(isNotEmpty(query.getPmrcontent4())) {
//            sql2.append(" and  t.pmrcontent4 = :pmrcontent4 ");
//        }
//        if(isNotEmpty(query.getPmrphone5())) {
//            sql2.append(" and  t.pmrphone5 = :pmrphone5 ");
//        }
//        if(isNotEmpty(query.getPmremail6())) {
//            sql2.append(" and  t.pmremail6 = :pmremail6 ");
//        }
//        if(isNotEmpty(query.getPmrstatue7())) {
//            sql2.append(" and  t.pmrstatue7 = :pmrstatue7 ");
//        }
//        if(isNotEmpty(query.getPmrtype8())) {
//            sql2.append(" and  t.pmrtype8 = :pmrtype8 ");
//        }
//        if(isNotEmpty(query.getSortColumns())) {
//            sql2.append(" order by :sortColumns ");
//        }	
        
		return pageQuery(sql,query);
	}
	

}
